package week_eight;

public class ValidAnagram_242 {
    public boolean isAnagram(String s, String t) {
        int[] countS = new int[26];
        // int[] countT = new int[26];
        if (s.length() != t.length()) return false;
        for (int i = 0; i < s.length(); i++) {
            countS[s.charAt(i) - 'a']++;
        }

        for (int i = 0; i < s.length(); i++) {
            countS[t.charAt(i) - 'a']--;
            if (countS[t.charAt(i) - 'a'] < 0) return false;
        }

        return true;
    }
}
